From: Julian Sparber Date: Thu, 7 Mar 2024 15:24:44 +0000 (+0100) Subject: appFavorites: Display its own notification for every pin/unpin X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~226^2^2~10 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ab4f80b8ae240a4b833d0de62dde38d615f3c701;p=gnome-shell.git appFavorites: Display its own notification for every pin/unpin Show a notification for each user action instead of updating the notification currently displayed when the user pins or unpins. Part-of: --- diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js index 576df3800..02ec93f15 100644 --- a/js/ui/appFavorites.js +++ b/js/ui/appFavorites.js @@ -1,11 +1,10 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- +import * as MessageTray from './messageTray.js'; import Shell from 'gi://Shell'; import * as ParentalControlsManager from '../misc/parentalControlsManager.js'; import * as Signals from '../misc/signals.js'; -import * as Main from './main.js'; - // In alphabetical order const RENAMED_DESKTOP_IDS = { 'baobab.desktop': 'org.gnome.baobab.desktop', @@ -161,13 +160,11 @@ class AppFavorites extends Signals.EventEmitter { if (!this._addFavorite(appId, pos)) return; - let app = Shell.AppSystem.get_default().lookup_app(appId); + const app = Shell.AppSystem.get_default().lookup_app(appId); - let msg = _('%s has been pinned to the dash.').format(app.get_name()); - Main.overview.setMessage(msg, { - forFeedback: true, - undoCallback: () => this._removeFavorite(appId), - }); + this._showNotification(_('%s has been pinned to the dash.').format(app.get_name()), + null, + () => this._removeFavorite(appId)); } addFavorite(appId) { @@ -196,11 +193,22 @@ class AppFavorites extends Signals.EventEmitter { if (!this._removeFavorite(appId)) return; - let msg = _('%s has been unpinned from the dash.').format(app.get_name()); - Main.overview.setMessage(msg, { + this._showNotification(_('%s has been unpinned from the dash.').format(app.get_name()), + null, + () => this._addFavorite(appId, pos)); + } + + _showNotification(title, body, undoCallback) { + const source = MessageTray.getSystemSource(); + const notification = new MessageTray.Notification({ + source, + title, + body, + isTransient: true, forFeedback: true, - undoCallback: () => this._addFavorite(appId, pos), }); + notification.addAction(_('Undo'), () => undoCallback()); + source.addNotification(notification); } }